using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SPGE
{
    public class StaticBackground : ABackground, ISimpleUpdatable
    {
        public override string Path
        { get; protected set; }

        Microsoft.Xna.Framework.Rectangle? sourceRect = null;
        public override Microsoft.Xna.Framework.Rectangle SourceRectangle
        {
            get
            {
                if (!sourceRect.HasValue)
                {
                    var height = Texture.Height > GameContainer.Device.PresentationParameters.BackBufferHeight ? 
                        GameContainer.Device.PresentationParameters.BackBufferHeight : Texture.Height;

                    var width = Texture.Width > GameContainer.Device.PresentationParameters.BackBufferWidth ?
                        GameContainer.Device.PresentationParameters.BackBufferWidth : Texture.Width;

                    sourceRect = new Rectangle(0, 0, width, height);
                }

                return sourceRect.Value;
            }
            set { sourceRect = value; }
        }

        public StaticBackground(string path)
        {
            this.Path = path;
            RenderLevel = 1f;
        }

        public override void Initialize()
        { }

        public override void Load(ResourceGroupHandler group)
        {
            base.Load(group);

            Size = new Vector2(GameContainer.Device.PresentationParameters.BackBufferWidth, GameContainer.Device.PresentationParameters.BackBufferHeight);
        }

        public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime)
        { }
   }
}
